﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SuccessPanel : BasePanel
{
    public Button exit_btn;
    public Button restart_btn;
    public Image levelImage;
    public List<Sprite> levelSprites;
    private void Awake()
    {
        exit_btn.onClick.AddListener(OnClickExit);
        restart_btn.onClick.AddListener(OnClickRestart);
    }
    public override void OnActive()
    {
        int level = GameManager.Instance.GetEvaluateLevel();
        if(level >= levelSprites.Count)
        {
            level = levelSprites.Count - 1;
        }
        if(level >= 0)
        {
            levelImage.sprite = levelSprites[level];
        }
    }

    private void OnClickExit()
    {
        AudioManager.Instance.PlayClick();
        UIManager.Instance.Open("ChoosePanel");
    }
    private void OnClickRestart()
    {
        AudioManager.Instance.PlayClick();
        GameManager.Instance.RestartGame();
        UIManager.Instance.Pop();
    }
}
